package com.drore.logapp.mvp;

import com.drore.logapp.bean.BaseBean;
import com.drore.logapp.bean.LogBean;
import com.drore.logapp.http.RetrofitTokenUtil;
import com.drore.logapp.http.token.HttpFileUtils;

import java.util.HashMap;
import java.util.Map;

import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * desc
 *
 * @author sixbing
 * @date 2018/12/11 15:46
 */

public class AppModel {
    public Observable<BaseBean<LogBean>> getLoganList(int page) {
        Map<String, Object> params = new HashMap<>();
        params.put("page", page);
        params.put("pageSize", 10);
        return RetrofitTokenUtil.getInstance().getHttpApi().getLoganList(HttpFileUtils.getRequestBody(params))
                .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<BaseBean<String>> loginToken() {
        Map<String, Object> params = new HashMap<>();
        params.put("token", "tokentokentokentoken");
        params.put("pageSize", "tokentokentokentoken");
        return RetrofitTokenUtil.getInstance().getHttpApi().loginToken(HttpFileUtils.getRequestBody(params))
                .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<BaseBean> getUserDetail() {
        String token = "tokentokentokentokentokentokentokentokentokentokentokentoken";
        return RetrofitTokenUtil.getInstance().getHttpApi().getUserDetail(token)
                .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
    }

    public Observable<BaseBean> getThingDetail() {
        String token = "tokentokentokentokentokentokentokentokentokentokentokentoken";
        Map<String, Object> params = new HashMap<>();
        params.put("page", "page");
        params.put("pageSize", "pageSize");
        return RetrofitTokenUtil.getInstance().getHttpApi().getThingDetail(token, HttpFileUtils.getRequestBody(params))
                .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
    }
    public Observable<BaseBean> getTimeOut() {
        return RetrofitTokenUtil.getNewInstance().getHttpApi().getTimeOut()
                .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
    }
}
